<template>
	<view class="reply">
	   <textarea v-model="content" placeholder="Say something..." />
	   <button @click.stop="handleRelease">{{$t('submit.submitButton')}}</button>
	</view>
</template>

<script>
import {getReplyReview} from "../../lib/service";
	import {
		showMessage,
		showFailure,
		showSuccess
	} from '../../lib/helper';
	export default{
		data(){
			return{
				reviewid:"",
				content:""
			}
		},
		onLoad(options) {
			this.reviewid = options.reviewid;
		},
		methods:{
			handleRelease(){
				let _this = this;
				if (!this.content) {
					showMessage('Please enter the reply content');
					return;
				}
				let obj = {
					reviewid: Number(this.reviewid),
					content: this.content,
				}
				getReplyReview(obj).then((res) => {
					showSuccess();
					setTimeout(() => {
						uni.navigateBack()
						}, 1000)
					})
					.catch((err) => {
						uni.hideLoading();
						showFailure();
					});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.reply{
		margin: 30rpx;
		textarea{
			width: 100%;
		}
		button{
			width: 100%;
			height: 88rpx;
			line-height: 88rpx;
			background-color: #FF3C15;
			color: #FFFFFF;
			border-radius: 36rpx;
			margin-top: 30rpx;
		}
	}
</style>